<?php


namespace app\admin\controller;


use think\admin\Controller;

/**
 * 图片管理
 * Class Images
 * @package app\admin\controller
 */
class Images extends Controller
{
    /**
     * 绑定数据表
     * @var string
     */
    private $table = 'lgFaceRecognition';

    /**
     * 图片列表
     * @auth true
     * @login true
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function index()
    {
        //标题
        $this->title = '图片管理';
        //门店
        $distributor = $this->app->db->table('lg_distributor')->order('id asc')->column('name', 'id');
        $this->assign('distributor', $distributor);

        $where = [];
        $equipment_id = input('equipment_id');
        $create_at = input('create_at');
        if ($equipment_id) {
            $where[] = ['f.equipment_id', 'like', '%' . $equipment_id . '%'];
        }
        if ($create_at) {
            $create_at = explode(' - ', $create_at);
            $where[] = ['f.create_time', 'between time', $create_at];
        }
        $query = $this->_query($this->table)->alias('f');
        $query->join('lg_distributor d','f.shop_id = d.id','left');
        $query->field('f.*,d.name as shop_name')->equal('shop_id');
        $query->where($where)->order('id desc')->page();
    }
}